'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db=uniCloud.database();
	// 插入数据时设置创建时间
	const date = new Date();
	const createTime = date.getTime();
		//添加数据到云数据库
		var id=await db.collection('message').add({
				username:event.username,
				phone:event.phone,
				email:event.email,
				content:event.content,
				create_time:createTime
			})
		if(id){
			return {
				code:200,
				msg:"提交完成"
			}
		}else{
			return {
				code:501,
				msg:"提交失败"
			}
		}
	//返回数据给客户端
	return event
};
